package com.migration.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

/**
 * 数据库配置基类
 */
@Data
public class DatabaseConfig {
    private String driver = "com.mysql.cj.jdbc.Driver";
    private String host = "localhost";
    private int port = 3306;
    private String username = "root";
    private String password = "";
    private String database = "";
    private String charset = "utf8mb4";
    
    /**
     * 获取JDBC连接URL
     * @return JDBC连接URL
     */
    public String getConnectionUrl() {
        return String.format("jdbc:mysql://%s:%d/%s?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&useSSL=false",
                host, port, database);
    }
}

/**
 * 源数据库配置（老数据库）
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "database.old")
class OldDatabaseConfig extends DatabaseConfig {
}

/**
 * 目标数据库配置（新数据库）
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "database.new")
class NewDatabaseConfig extends DatabaseConfig {
} 